/*
 * @Description: 
 * @Author: menglong.du
 * @Date: 2021-12-05 14:02:29
 * @LastEditTime: 2021-12-05 17:53:09
 * @LastEditors: menglong.du
 */
var superPow = function(a, b) {
  if(a===1) return a
  let ans = BigInt(1);
  for(var i=b.length-1;i>=0;i--) {
    ans = ans * pow(BigInt(a),b[i]) % BigInt(1337)
    a = pow(BigInt(a),10) // a的10次方 100 1000
    console.log(a)
    console.log(ans)
  }
  return ans
};

var pow = (a,b) => {
  let ans = BigInt(1)
  while(b!==0) {
    if(b%2!==0) {
      ans = ans * a % BigInt(1337)
    }
    a = a*a%BigInt(1337)
    b>>=1
  }
  return ans
}

console.log(superPow(2,[3,2]))
